#ifndef PP_GENERATOR_H
#define PP_GENERATOR_H

#include "pp_parser.h"
#include "code_generator.h"

#define PP_GEN_VERSION "1.0.3"

namespace pp
{
    class CodeHandler : public ParseHandler
    {
    private:
        std::shared_ptr<StructInfo> m_oCurStruct;
        std::shared_ptr<CodeGenerator> m_oCodeGenerator;
    public:
        CodeHandler(std::shared_ptr<CodeGenerator>& codeGenerator) : m_oCodeGenerator(codeGenerator) {}
    public:
        virtual void StartElement(const std::string& name, const std::map<std::string, std::string>& attrs);
        virtual void EndElement(const std::string& name);
    };

    class Generator
    {
    private:
        std::string m_sSrcDir;                          // 协议文件查找路径
        std::string m_sOutdir;                          // 文件输出路径
        std::shared_ptr<CodeGenerator> m_oCodeGenerator;
        std::shared_ptr<CodeHandler> m_oCodeHandler;    // code handler
        Parser m_oParser;                               // pp parse
    public:
        Generator(const std::string& language, const std::string& srcdir, const std::string& outdir);
    public:
        void Generate(const std::string& fname);
    };
};

#endif
